Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Dynamic array</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Dynamic_array"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Dynamic_array rootpage-Dynamic_array skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Dynamic array</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">

<p>In <a href="Computer_science" title="Computer science">computer science</a>, a <b>dynamic array</b>, <b>growable array</b>, <b>resizable array</b>, <b>dynamic table</b>, <b>mutable array</b>, or <b>array list</b> is a <a href="Random_access" title="Random access">random access</a>, variable-size <a href="List_data_structure" class="mw-redirect" title="List data structure">list data structure</a> that allows elements to be added or removed. It is supplied with <a href="Standard_libraries" class="mw-redirect" title="Standard libraries">standard libraries</a> in many modern mainstream <a href="Programming_language" title="Programming language">programming languages</a>. Dynamic arrays overcome a limit of static <a href="Array_data_type" class="mw-redirect" title="Array data type">arrays</a>, which have a fixed capacity that needs to be specified at <a href="Memory_management" title="Memory management">allocation</a>.
</p><p>A dynamic array is not the same thing as a <a href="Dynamic_memory_allocation" class="mw-redirect" title="Dynamic memory allocation">dynamically allocated</a> array or <a href="Variable-length_array" title="Variable-length array">variable-length array</a>, either of which is an array whose size is fixed when the array is allocated, although a dynamic array may use such a fixed-size array as a back end.<sup id="cite_ref-java_util_ArrayList_1-0" class="reference"><a href="#cite_note-java_util_ArrayList-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Bounded-size_dynamic_arrays_and_capacity">Bounded-size dynamic arrays and capacity</h2></div>
<p>A simple dynamic array can be constructed by allocating an array of fixed-size, typically larger than the number of elements immediately required. The elements of the dynamic array are stored contiguously at the start of the underlying array, and the remaining positions towards the end of the underlying array are reserved, or unused. Elements can be added at the end of a dynamic array in <a href="Time_complexity#Constant_time" title="Time complexity">constant time</a> by using the reserved space, until this space is completely consumed. When all space is consumed, and an additional element is to be added, then the underlying fixed-size array needs to be increased in size. Typically resizing is expensive because it involves allocating a new underlying array and copying each element from the original array. Elements can be removed from the end of a dynamic array in constant time, as no resizing is required. The number of elements used by the dynamic array contents is its <i>logical size</i> or <i>size</i>, while the size of the underlying array is called the dynamic array's <i>capacity</i> or <i>physical size</i>, which is the maximum possible size without relocating data.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p><p>A fixed-size array will suffice in applications where the maximum logical size is fixed (e.g. by specification), or can be calculated before the array is allocated. A dynamic array might be preferred if:
</p>
<ul><li>the maximum logical size is unknown, or difficult to calculate, before the array is allocated</li>
<li>it is considered that a maximum logical size given by a specification is likely to change</li>
<li>the amortized cost of resizing a dynamic array does not significantly affect performance or responsiveness</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Geometric_expansion_and_amortized_cost">Geometric expansion and amortized cost</h2></div>
<p>To avoid incurring the cost of resizing many times, dynamic arrays resize by a large amount, such as doubling in size, and use the reserved space for future expansion. The operation of adding an element to the end might work as follows:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">function</span><span class="w"> </span><span class="n">insertEnd</span><span class="p">(</span><span class="n">dynarray</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">element</span><span class="w"> </span><span class="n">e</span><span class="p">)</span>
<span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="p">.</span><span class="n">size</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">capacity</span><span class="p">)</span>
<span class="w"> </span><span class="c1">// resize a to twice its current capacity:</span>
<span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">capacity</span><span class="w"> </span><span class="err">←</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">capacity</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span>
<span class="w"> </span><span class="c1">// (copy the contents to the new memory location here)</span>
<span class="w"> </span><span class="n">a</span><span class="p">[</span><span class="n">a</span><span class="p">.</span><span class="n">size</span><span class="p">]</span><span class="w"> </span><span class="err">←</span><span class="w"> </span><span class="n">e</span>
<span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">size</span><span class="w"> </span><span class="err">←</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">size</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span>
</pre></div>
<p>As <i>n</i> elements are inserted, the capacities form a <a href="Geometric_progression" title="Geometric progression">geometric progression</a>. Expanding the array by any constant proportion <i>a</i> ensures that inserting <i>n</i> elements takes <a href="Big_O_notation" title="Big O notation"><i>O</i>(<i>n</i>)</a> time overall, meaning that each insertion takes <a href="Amortized_analysis" title="Amortized analysis">amortized</a> constant time. Many dynamic arrays also deallocate some of the underlying storage if its size drops below a certain threshold, such as 30% of the capacity. This threshold must be strictly smaller than 1/<i>a</i> in order to provide <a href="Hysteresis" title="Hysteresis">hysteresis</a> (provide a stable band to avoid repeatedly growing and shrinking) and support mixed sequences of insertions and removals with amortized constant cost.
</p><p>Dynamic arrays are a common example when teaching <a href="Amortized_analysis" title="Amortized analysis">amortized analysis</a>.<sup id="cite_ref-gt-ad_3-0" class="reference"><a href="#cite_note-gt-ad-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-clrs_4-0" class="reference"><a href="#cite_note-clrs-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Growth_factor">Growth factor</h2></div>
<p>The growth factor for the dynamic array depends on several factors including a space-time trade-off and algorithms used in the memory allocator itself. For growth factor <i>a</i>, the average time per insertion operation is <span class="citation-needed-content" style="padding-left:0.1em; padding-right:0.1em; color:var(--color-subtle, #54595d); border:1px solid var(--border-color-subtle, #c8ccd1);">about <i>a</i>/(<i>a</i>−1), while the number of wasted cells is bounded above by (<i>a</i>−1)<i>n</i></span>. If memory allocator uses a <a href="First_fit_algorithm" class="mw-redirect" title="First fit algorithm">first-fit allocation</a> algorithm, then growth factor values such as <i>a</i>=2 can cause dynamic array expansion to run out of memory even though a significant amount of memory may still be available.<sup id="cite_ref-:0_5-0" class="reference"><a href="#cite_note-:0-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> There have been various discussions on ideal growth factor values, including proposals for the <a href="Golden_ratio" title="Golden ratio">golden ratio</a> as well as the value 1.5.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> Many textbooks, however, use <i>a</i>&nbsp;=&nbsp;2 for simplicity and analysis purposes.<sup id="cite_ref-gt-ad_3-1" class="reference"><a href="#cite_note-gt-ad-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-clrs_4-1" class="reference"><a href="#cite_note-clrs-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p>Below are growth factors used by several popular implementations:
</p>
<table class="wikitable">
<tbody><tr>
<th>Implementation
</th>
<th>Growth factor (<i>a</i>)
</th></tr>
<tr>
<td>Java ArrayList<sup id="cite_ref-java_util_ArrayList_1-1" class="reference"><a href="#cite_note-java_util_ArrayList-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</td>
<td>1.5 (3/2)
</td></tr>
<tr>
<td><a href="Python_(programming_language)" title="Python (programming language)">Python</a> PyListObject<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</td>
<td>~1.125 (n + (n &gt;&gt; 3))
</td></tr>
<tr>
<td><a href="Microsoft_Visual_C%2B%2B" title="Microsoft Visual C++">Microsoft Visual C++</a> 2013<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</td>
<td>1.5 (3/2)
</td></tr>
<tr>
<td><a href="G%2B%2B" class="mw-redirect" title="G++">G++</a> 5.2.0<sup id="cite_ref-:0_5-1" class="reference"><a href="#cite_note-:0-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</td>
<td>2
</td></tr>
<tr>
<td><a href="Clang" title="Clang">Clang</a> 3.6<sup id="cite_ref-:0_5-2" class="reference"><a href="#cite_note-:0-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</td>
<td>2
</td></tr>
<tr>
<td>Facebook folly/FBVector<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</td>
<td>1.5 (3/2)
</td></tr>
<tr>
<td><a href="Unreal_Engine" title="Unreal Engine">Unreal Engine</a> TArray<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</td>
<td>~1.375 (n + ((3 * n) &gt;&gt; 3))
</td></tr>
<tr>
<td>Rust Vec<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</td>
<td>2
</td></tr>
<tr>
<td><a href="Go_(programming_language)" title="Go (programming language)">Go</a> slices<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</td>
<td>between 1.25 and 2
</td></tr>
<tr>
<td><a href="Nim_(programming_language)" title="Nim (programming language)">Nim</a> sequences<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup>
</td>
<td>2
</td></tr>
<tr>
<td><a href="Steel_Bank_Common_Lisp" title="Steel Bank Common Lisp">SBCL</a> (<a href="Common_Lisp" title="Common Lisp">Common Lisp</a>) vectors<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup>
</td>
<td>2
</td></tr>
<tr>
<td><a href="C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a> (<a href=".NET" title=".NET">.NET</a> 8) List
</td>
<td>2
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="Performance">Performance</h2></div>
<table class="wikitable">
<caption>Comparison of list data structures
</caption>
<tbody><tr>
<th rowspan="2">
</th>
<th rowspan="2">Peek <br>(index)
</th>
<th colspan="3">Mutate (insert or delete) at …
</th>
<th rowspan="2">Excess space, <br>average
</th></tr>
<tr>
<th>Beginning
</th>
<th>End
</th>
<th>Middle
</th></tr>
<tr>
<td><a href="Linked_list" title="Linked list">Linked list</a>
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1)
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1), known end element;<br>Θ(<i>n</i>), unknown end element
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td></tr>
<tr>
<td><a href="Array_data_structure" class="mw-redirect" title="Array data structure">Array</a>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1)
</td>
<td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—
</td>
<td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—
</td>
<td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">0
</td></tr>
<tr>
<td>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1)
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) <a href="Amortized_analysis" title="Amortized analysis">amortized</a>
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</td></tr>
<tr>
<td><a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Balanced tree</a>
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n)
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n)
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log <i>n</i>)
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log <i>n</i>)
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td></tr>
<tr>
<td>Random-<span class="nowrap">access list</span>
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(log n)<sup id="cite_ref-okasakiComparison_16-0" class="reference"><a href="#cite_note-okasakiComparison-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1)
</td>
<td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—<sup id="cite_ref-okasakiComparison_16-1" class="reference"><a href="#cite_note-okasakiComparison-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</td>
<td data-sort-value="" style="background: var(--background-color-interactive, #ececec); color: var(--color-base, inherit); vertical-align: middle; text-align: center;" class="table-na">—<sup id="cite_ref-okasakiComparison_16-2" class="reference"><a href="#cite_note-okasakiComparison-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td></tr>
<tr>
<td><a href="Hashed_array_tree" title="Hashed array tree">Hashed array tree</a>
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1)
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Θ(1) <a href="Amortized_analysis" title="Amortized analysis">amortized</a>
</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">Θ(<i>n</i>)
</td>
<td style="background:#FFB; color:black;vertical-align:middle;text-align:center;" class="table-partial">Θ(√<i>n</i>)
</td></tr></tbody></table>
<p>The dynamic array has performance similar to an array, with the addition of new operations to add and remove elements:
</p>
<ul><li>Getting or setting the value at a particular index (constant time)</li>
<li>Iterating over the elements in order (linear time, good cache performance)</li>
<li>Inserting or deleting an element in the middle of the array (linear time)</li>
<li>Inserting or deleting an element at the end of the array (constant amortized time)</li></ul>
<p>Dynamic arrays benefit from many of the advantages of arrays, including good <a href="Locality_of_reference" title="Locality of reference">locality of reference</a> and <a href="Data_cache" class="mw-redirect" title="Data cache">data cache</a> utilization, compactness (low memory use), and <a href="Random_access" title="Random access">random access</a>. They usually have only a small fixed additional overhead for storing information about the size and capacity. This makes dynamic arrays an attractive tool for building <a href="Cache_(computing)" title="Cache (computing)">cache</a>-friendly <a href="Data_structure" title="Data structure">data structures</a>. However, in languages like Python or Java that enforce reference semantics, the dynamic array generally will not store the actual data, but rather it will store <a href="Reference_(computer_science)" title="Reference (computer science)">references</a> to the data that resides in other areas of memory. In this case, accessing items in the array sequentially will actually involve accessing multiple non-contiguous areas of memory, so the many advantages of the cache-friendliness of this data structure are lost.
</p><p>Compared to <a href="Linked_list" title="Linked list">linked lists</a>, dynamic arrays have faster indexing (constant time versus linear time) and typically faster iteration due to improved locality of reference; however, dynamic arrays require linear time to insert or delete at an arbitrary location, since all following elements must be moved, while linked lists can do this in constant time. This disadvantage is mitigated by the <a href="Gap_buffer" title="Gap buffer">gap buffer</a> and <i>tiered vector</i> variants discussed under <i>Variants</i> below. Also, in a highly <a href="Fragmentation_(computer)" class="mw-redirect" title="Fragmentation (computer)">fragmented</a> memory region, it may be expensive or impossible to find contiguous space for a large dynamic array, whereas linked lists do not require the whole data structure to be stored contiguously.
</p><p>A <a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">balanced tree</a> can store a list while providing all operations of both dynamic arrays and linked lists reasonably efficiently, but both insertion at the end and iteration over the list are slower than for a dynamic array, in theory and in practice, due to non-contiguous storage and tree traversal/manipulation overhead.
</p>
<div class="mw-heading mw-heading2"><h2 id="Variants">Variants</h2></div>
<p><a href="Gap_buffer" title="Gap buffer">Gap buffers</a> are similar to dynamic arrays but allow efficient insertion and deletion operations clustered near the same arbitrary location. Some <a href="Deque" class="mw-redirect" title="Deque">deque</a> implementations use <a href="Deque" class="mw-redirect" title="Deque">array deques</a>, which allow amortized constant time insertion/removal at both ends, instead of just one end.
</p><p>Goodrich<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> presented a dynamic array algorithm called <i>tiered vectors</i> that provides <i>O</i>(<i>n</i><sup>1/<i>k</i></sup>) performance for insertions and deletions from anywhere in the array, and <i>O</i>(<i>k</i>) get and set, where <i>k</i> ≥ 2 is a constant parameter.
</p><p><a href="Hashed_array_tree" title="Hashed array tree">Hashed array tree</a> (HAT) is a dynamic array algorithm published by Sitarski in 1996.<sup id="cite_ref-sitarski96_18-0" class="reference"><a href="#cite_note-sitarski96-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> Hashed array tree wastes order <i>n</i><sup>1/2</sup> amount of storage space, where <i>n</i> is the number of elements in the array. The algorithm has <i>O</i>(1) amortized performance when appending a series of objects to the end of a hashed array tree.
</p><p>In a 1999 paper,<sup id="cite_ref-brodnik_19-0" class="reference"><a href="#cite_note-brodnik-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup> Brodnik et al. describe a tiered dynamic array data structure, which wastes only <i>n</i><sup>1/2</sup> space for <i>n</i> elements at any point in time, and they prove a lower bound showing that any dynamic array must waste this much space if the operations are to remain amortized constant time. Additionally, they present a variant where growing and shrinking the buffer has not only amortized but worst-case constant time.
</p><p>Bagwell (2002)<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup> presented the VList algorithm, which can be adapted to implement a dynamic array.
</p><p>Naïve resizable arrays -- also called "the worst implementation" of resizable arrays -- keep the allocated size of the array exactly big enough for all the data it contains, perhaps by calling <a href="Realloc" class="mw-redirect" title="Realloc">realloc</a> for each and every item added to the array. Naïve resizable arrays are the simplest way of implementing a resizable array in C. They don't waste any memory, but appending to the end of the array always takes Θ(<i>n</i>) time.<sup id="cite_ref-sitarski96_18-1" class="reference"><a href="#cite_note-sitarski96-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
Linearly growing arrays pre-allocate ("waste") Θ(1) space every time they re-size the array, making them many times faster than naïve resizable arrays -- appending to the end of the array still takes Θ(<i>n</i>) time but with a much smaller constant.
Naïve resizable arrays and linearly growing arrays may be useful when a space-constrained application needs lots of small resizable arrays;
they are also commonly used as an educational example leading to exponentially growing dynamic arrays.<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Language_support">Language support</h2></div>
<p><a href="C%2B%2B" title="C++">C++</a>'s <a href="Vector_(C%2B%2B)" class="mw-redirect" title="Vector (C++)"><code>std::vector</code></a> and <a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a>'s <code>std::vec::Vec</code> are implementations of dynamic arrays, as are the <code>ArrayList</code><sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup> classes supplied with the <a href="Java_(programming_language)" title="Java (programming language)">Java</a> API<sup id="cite_ref-Bloch_27-0" class="reference"><a href="#cite_note-Bloch-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Page / location: 236">: 236 </span></sup> and the <a href=".NET_Framework" title=".NET Framework">.NET Framework</a>.<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Skeet_29-0" class="reference"><a href="#cite_note-Skeet-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup><sup class="reference nowrap"><span title="Page / location: 22">: 22 </span></sup>
</p><p>The generic <code>List&lt;&gt;</code> class supplied with version 2.0 of the .NET Framework is also implemented with dynamic arrays. <a href="Smalltalk" title="Smalltalk">Smalltalk</a>'s <code>OrderedCollection</code> is a dynamic array with dynamic start and end-index, making the removal of the first element also O(1).
</p><p><a href="Python_(Programming_Language)" class="mw-redirect" title="Python (Programming Language)">Python</a>'s <code>list</code> datatype implementation is a dynamic array the growth pattern of which is: 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, ...<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup>
</p><p><a href="Delphi_(programming_language)" class="mw-redirect" title="Delphi (programming language)">Delphi</a> and <a href="D_(programming_language)" title="D (programming language)">D</a> implement dynamic arrays at the language's core.
</p><p><a href="Ada_(programming_language)" title="Ada (programming language)">Ada</a>'s <a href="https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Containers.Vectors" class="extiw external" title="wikibooks:Ada Programming/Libraries/Ada.Containers.Vectors"><code>Ada.Containers.Vectors</code></a> generic package provides dynamic array implementation for a given subtype.
</p><p>Many scripting languages such as <a href="Perl" title="Perl">Perl</a> and <a href="Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> offer dynamic arrays as a built-in <a href="Primitive_data_type" title="Primitive data type">primitive data type</a>.
</p><p>Several cross-platform frameworks provide dynamic array implementations for <a href="C_(programming_language)" title="C (programming language)">C</a>, including <code>CFArray</code> and <code>CFMutableArray</code> in <a href="Core_Foundation" title="Core Foundation">Core Foundation</a>, and <code>GArray</code> and <code>GPtrArray</code> in <a href="GLib" title="GLib">GLib</a>.
</p><p><a href="Common_Lisp" title="Common Lisp">Common Lisp</a> provides a rudimentary support for resizable vectors by allowing to configure the built-in <code>array</code> type as <i>adjustable</i> and the location of insertion by the <i>fill-pointer</i>.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Stack_(data_structure)" class="mw-redirect" title="Stack (data structure)">Stack (data structure)</a></li>
<li><a href="Queue_(data_structure)" class="mw-redirect" title="Queue (data structure)">Queue (data structure)</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-java_util_ArrayList-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-java_util_ArrayList_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-java_util_ArrayList_1-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">See, for example, the <a rel="nofollow" class="external text" href="http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/e0e25ac28560/src/share/classes/java/util/ArrayList.java">source code of java.util.ArrayList class from OpenJDK 6</a>.</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFLambert,_Kenneth_Alfred2009" class="citation cs2">Lambert, Kenneth Alfred (2009), <a rel="nofollow" class="external text" href="https://books.google.com/books?id=VtfM3YGW5jYC&amp;q=%22logical+size%22+%22dynamic+array%22&amp;pg=PA518">"Physical size and logical size"</a>, <i>Fundamentals of Python: From First Programs Through Data Structures</i>, Cengage Learning, p.&nbsp;510, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1423902188</bdi></cite></span>
</li>
<li id="cite_note-gt-ad-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-gt-ad_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-gt-ad_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFGoodrichTamassia2002" class="citation cs2"><a href="Michael_T._Goodrich" title="Michael T. Goodrich">Goodrich, Michael T.</a>; <a href="Roberto_Tamassia" title="Roberto Tamassia">Tamassia, Roberto</a> (2002), "1.5.2 Analyzing an Extendable Array Implementation", <i>Algorithm Design: Foundations, Analysis and Internet Examples</i>, Wiley, pp.&nbsp;<span class="nowrap">39–</span>41</cite>.</span>
</li>
<li id="cite_note-clrs-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-clrs_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-clrs_4-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFCormenLeisersonRivestStein2001" class="citation book cs1"><a href="Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="Ron_Rivest" title="Ron Rivest">Rivest, Ronald L.</a>; <a href="Clifford_Stein" title="Clifford Stein">Stein, Clifford</a> (2001) [1990]. "17.4 Dynamic tables". <a href="Introduction_to_Algorithms" title="Introduction to Algorithms"><i>Introduction to Algorithms</i></a> (2nd&nbsp;ed.). MIT Press and McGraw-Hill. pp.&nbsp;<span class="nowrap">416–</span>424. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>0-262-03293-7</bdi>.</cite></span>
</li>
<li id="cite_note-:0-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-:0_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-:0_5-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-:0_5-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20150806162750/http://www.gahcep.com/cpp-internals-stl-vector-part-1/">"C++ STL vector: definition, growth factor, member functions"</a>. Archived from <a rel="nofollow" class="external text" href="http://www.gahcep.com/cpp-internals-stl-vector-part-1/">the original</a> on 2015-08-06<span class="reference-accessdate">. Retrieved <span class="nowrap">2015-08-05</span></span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://arquivo.pt/wayback/20110122130054/https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/asH_VojWKJw%5B1-25%5D">"vector growth factor of 1.5"</a>. <i>comp.lang.c++.moderated</i>. Google Groups. Archived from <a rel="nofollow" class="external text" href="https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/asH_VojWKJw%5B1-25%5D">the original</a> on 2011-01-22<span class="reference-accessdate">. Retrieved <span class="nowrap">2015-08-05</span></span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://github.com/python/cpython/blob/bace59d8b8e38f5c779ff6296ebdc0527f6db14a/Objects/listobject.c#L58">List object implementation</a> from github.com/python/cpython/, retrieved 2020-03-23.</span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrais2013" class="citation web cs1">Brais, Hadi (15 November 2013). <a rel="nofollow" class="external text" href="https://hadibrais.wordpress.com/2013/11/15/dissecting-the-c-stl-vector-part-3-capacity/">"Dissecting the C++ STL Vector: Part 3 - Capacity &amp; Size"</a>. <i>Micromysteries</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2015-08-05</span></span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md">"facebook/folly"</a>. <i>GitHub</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2015-08-05</span></span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://forums.unrealengine.com/t/nested-tarrays-in-structs-and-memory/2357416/3">"Nested TArrays in structs and memory"</a>. <i>Epic Developer Community Forums</i>. 2025-02-26<span class="reference-accessdate">. Retrieved <span class="nowrap">2025-05-26</span></span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/rust-lang/rust/blob/fd4b177aabb9749dfb562c48e47379cea81dc277/src/liballoc/raw_vec.rs#L443">"rust-lang/rust"</a>. <i>GitHub</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-06-09</span></span>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/golang/go/blob/master/src/runtime/slice.go#L188">"golang/go"</a>. <i>GitHub</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-09-14</span></span>.</cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://zevv.nl/nim-memory/#_growing_a_seq">"The Nim memory model"</a>. <i>zevv.nl</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2022-05-24</span></span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/sbcl/sbcl/blob/master/src/code/array.lisp#L1200-L1204">"sbcl/sbcl"</a>. <i>GitHub</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-02-15</span></span>.</cite></span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrodnikCarlssonSedgewickMunro1999" class="citation cs2">Brodnik, Andrej; Carlsson, Svante; <a href="Robert_Sedgewick_(computer_scientist)" title="Robert Sedgewick (computer scientist)">Sedgewick, Robert</a>; Munro, JI; Demaine, ED (1999), <a rel="nofollow" class="external text" href="http://www.cs.uwaterloo.ca/research/tr/1999/09/CS-99-09.pdf"><i>Resizable Arrays in Optimal Time and Space (Technical Report CS-99-09)</i></a> <span class="cs1-format">(PDF)</span>, Department of Computer Science, University of Waterloo</cite></span>
</li>
<li id="cite_note-okasakiComparison-16"><span class="mw-cite-backlink">^ <a href="#cite_ref-okasakiComparison_16-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-okasakiComparison_16-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-okasakiComparison_16-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFChris_Okasaki1995" class="citation journal cs1">Chris Okasaki (1995). "Purely Functional Random-Access Lists". <i>Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture</i>: <span class="nowrap">86–</span>95. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F224164.224187">10.1145/224164.224187</a>.</cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite id="CITEREFGoodrichKloss_II1999" class="citation cs2"><a href="Michael_T._Goodrich" title="Michael T. Goodrich">Goodrich, Michael T.</a>; Kloss II, John G. (1999), <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/algorithmsdatast0000wads/page/205">"Tiered Vectors: Efficient Dynamic Arrays for Rank-Based Sequences"</a></span>, <i><a href="Workshop_on_Algorithms_and_Data_Structures" class="mw-redirect" title="Workshop on Algorithms and Data Structures">Workshop on Algorithms and Data Structures</a></i>, Lecture Notes in Computer Science, <b>1663</b>: <a rel="nofollow" class="external text" href="https://archive.org/details/algorithmsdatast0000wads/page/205">205–216</a>, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F3-540-48447-7_21">10.1007/3-540-48447-7_21</a>, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-3-540-66279-2</bdi></cite></span>
</li>
<li id="cite_note-sitarski96-18"><span class="mw-cite-backlink">^ <a href="#cite_ref-sitarski96_18-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-sitarski96_18-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFSitarski1996" class="citation cs2">Sitarski, Edward (September 1996), <a rel="nofollow" class="external text" href="http://www.ddj.com/architect/184409965?pgno=5">"HATs: Hashed array trees"</a>, Algorithm Alley, <i>Dr. Dobb's Journal</i>, <b>21</b> (11)</cite></span>
</li>
<li id="cite_note-brodnik-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-brodnik_19-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrodnikCarlssonSedgewickMunro1999" class="citation cs2">Brodnik, Andrej; Carlsson, Svante; <a href="Robert_Sedgewick_(computer_scientist)" title="Robert Sedgewick (computer scientist)">Sedgewick, Robert</a>; Munro, JI; Demaine, ED (1999), <a rel="nofollow" class="external text" href="http://www.cs.uwaterloo.ca/research/tr/1999/09/CS-99-09.pdf"><i>Resizable Arrays in Optimal Time and Space</i></a> <span class="cs1-format">(PDF)</span> (Technical Report CS-99-09), Department of Computer Science, University of Waterloo</cite></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite id="CITEREFBagwell2002" class="citation cs2">Bagwell, Phil (2002), <a rel="nofollow" class="external text" href="http://citeseer.ist.psu.edu/bagwell02fast.html"><i>Fast Functional Lists, Hash-Lists, Deques and Variable Length Arrays</i></a>, EPFL</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text">
Mike Lam.
<a rel="nofollow" class="external text" href="https://w3.cs.jmu.edu/lam2mo/cs240_2015_08/files/04-dyn_arrays.pdf">"Dynamic Arrays"</a>.</span>
</li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://users.cs.northwestern.edu/~jesse/course/cs214-fa19/lec/17-amortized.pdf">"Amortized Time"</a>.</span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://iq.opengenus.org/hashed-array-tree/">"Hashed Array Tree: Efficient representation of Array"</a>.</span>
</li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://people.ksp.sk/~kuko/gnarley-trees/Complexity2.html">"Different notions of complexity"</a>.</span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text">
Peter Kankowski.
<a rel="nofollow" class="external text" href="https://www.strchr.com/dynamic_arrays">"Dynamic arrays in C"</a>.</span>
</li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text">Javadoc on <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/ArrayList.html">ArrayList</a></code></span>
</li>
<li id="cite_note-Bloch-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-Bloch_27-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFBloch2018" class="citation book cs1">Bloch, Joshua (2018). <i>"Effective Java: Programming Language Guide"</i> (third&nbsp;ed.). Addison-Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0134685991</bdi>.</cite></span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://msdn.microsoft.com/en-us/library/system.collections.arraylist">ArrayList Class</a></span>
</li>
<li id="cite_note-Skeet-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-Skeet_29-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSkeet2019" class="citation book cs1">Skeet, Jon (23 March 2019). <i>C# in Depth</i>. Manning. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-1617294532</bdi>.</cite></span>
</li>
<li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://github.com/python/cpython/blob/bace59d8b8e38f5c779ff6296ebdc0527f6db14a/Objects/listobject.c#L58">listobject.c (github.com)</a></span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="https://xlinux.nist.gov/dads/HTML/dynamicarray.html">NIST Dictionary of Algorithms and Data Structures: Dynamic array</a></li>
<li><a rel="nofollow" class="external text" href="http://www.bsdua.org/libbsdua.html#vpool">VPOOL</a> - C language implementation of dynamic array.</li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20090704095801/http://www.collectionspy.com/">CollectionSpy</a> — A Java profiler with explicit support for debugging ArrayList- and Vector-related issues.</li>
<li><a rel="nofollow" class="external text" href="http://opendatastructures.org/versions/edition-0.1e/ods-java/2_Array_Based_Lists.html">Open Data Structures - Chapter 2 - Array-Based Lists</a>, <a href="Pat_Morin" title="Pat Morin">Pat Morin</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Data_structures216" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */


.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div id="Data_structures216" style="font-size:114%;margin:0 4em"><a href="Data_structure" title="Data structure">Data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Types</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Collection_(abstract_data_type)" title="Collection (abstract data type)">Collection</a></li>
<li><a href="Container_(abstract_data_type)" title="Container (abstract data type)">Container</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Abstract_data_type" title="Abstract data type">Abstract</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Associative_array" title="Associative array">Associative array</a>
<ul><li><a href="Multimap" title="Multimap">Multimap</a></li>
<li><a href="Retrieval_Data_Structure" title="Retrieval Data Structure">Retrieval Data Structure</a></li></ul></li>
<li><a href="List_(abstract_data_type)" title="List (abstract data type)">List</a></li>
<li><a href="Stack_(abstract_data_type)" title="Stack (abstract data type)">Stack</a></li>
<li><a href="Queue_(abstract_data_type)" title="Queue (abstract data type)">Queue</a>
<ul><li><a href="Double-ended_queue" title="Double-ended queue">Double-ended queue</a></li></ul></li>
<li><a href="Priority_queue" title="Priority queue">Priority queue</a>
<ul><li><a href="Double-ended_priority_queue" title="Double-ended priority queue">Double-ended priority queue</a></li></ul></li>
<li><a href="Set_(abstract_data_type)" title="Set (abstract data type)">Set</a>
<ul><li><a href="Set_(abstract_data_type)#Multiset" title="Set (abstract data type)">Multiset</a></li>
<li><a href="Disjoint-set_data_structure" title="Disjoint-set data structure">Disjoint-set</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Array_(data_structure)" title="Array (data structure)">Arrays</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_array" title="Bit array">Bit array</a></li>
<li><a href="Circular_buffer" title="Circular buffer">Circular buffer</a></li>

<li><a href="Hash_table" title="Hash table">Hash table</a></li>
<li><a href="Hashed_array_tree" title="Hashed array tree">Hashed array tree</a></li>
<li><a href="Sparse_matrix" title="Sparse matrix">Sparse matrix</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Linked_data_structure" title="Linked data structure">Linked</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Association_list" title="Association list">Association list</a></li>
<li><a href="Linked_list" title="Linked list">Linked list</a></li>
<li><a href="Skip_list" title="Skip list">Skip list</a></li>
<li><a href="Unrolled_linked_list" title="Unrolled linked list">Unrolled linked list</a></li>
<li><a href="XOR_linked_list" title="XOR linked list">XOR linked list</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">Trees</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="B-tree" title="B-tree">B-tree</a></li>
<li><a href="Binary_search_tree" title="Binary search tree">Binary search tree</a>
<ul><li><a href="AA_tree" title="AA tree">AA tree</a></li>
<li><a href="AVL_tree" title="AVL tree">AVL tree</a></li>
<li><a href="Red%E2%80%93black_tree" title="Red–black tree">Red–black tree</a></li>
<li><a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Self-balancing tree</a></li>
<li><a href="Splay_tree" title="Splay tree">Splay tree</a></li></ul></li>
<li><a href="Heap_(data_structure)" title="Heap (data structure)">Heap</a>
<ul><li><a href="Binary_heap" title="Binary heap">Binary heap</a></li>
<li><a href="Binomial_heap" title="Binomial heap">Binomial heap</a></li>
<li><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a></li></ul></li>
<li><a href="R-tree" title="R-tree">R-tree</a>
<ul><li><a href="R*_tree" class="mw-redirect" title="R* tree">R* tree</a></li>
<li><a href="R%2B_tree" title="R+ tree">R+ tree</a></li>
<li><a href="Hilbert_R-tree" title="Hilbert R-tree">Hilbert R-tree</a></li></ul></li>
<li><a href="Trie" title="Trie">Trie</a>
<ul><li><a href="Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash tree</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Graph_(abstract_data_type)" title="Graph (abstract data type)">Graphs</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_decision_diagram" title="Binary decision diagram">Binary decision diagram</a></li>
<li><a href="Directed_acyclic_graph" title="Directed acyclic graph">Directed acyclic graph</a></li>
<li><a href="Deterministic_acyclic_finite_state_automaton" title="Deterministic acyclic finite state automaton">Directed acyclic word graph</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><a href="List_of_data_structures" title="List of data structures">List of data structures</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-05-26" href="https://en.wikipedia.org/wiki/?title=Dynamic_array&amp;oldid=1292303927">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>